
#include <QCoreApplication>
#include <QTextStream>
#include <QDebug>

#include <QDBusConnection>

void log(const QString log)
{
    QTextStream out(stdout);
    out << log << "\n";
    out.flush();
}

QDBusConnection getSystemBus()
{
    return QDBusConnection::systemBus();
}
QDBusConnection getSessionBus()
{
    return QDBusConnection::sessionBus();
}

void testConnectBus()
{
    QTextStream out(stdout);
    QDBusConnection systemBus = QDBusConnection::systemBus();
    QDBusConnection sessionBus = QDBusConnection::sessionBus();

    if (systemBus.isConnected())
    {
        log("systemBus: Bus is connected.");
    }
    if (sessionBus.isConnected())
    {
        log("sessionBus: Bus is connected.");
    }
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // 1. 测试连接到总线
    testConnectBus();

    return 0;
}

